﻿var GetRoom = {};

GetRoom.Init = function() {

//初始化GetRoom对象的方法和属性Start
//修改栋座信息及选中栋座信息动态刷新单元数据  
    GetRoom.getUnitsByIFFlags = function(msg) {
        $('#hNUnitsId').unbind();
        $('#hNUnitsId').html("");
        var opt = '<option value="0">--请选择条件--</option>';
        $(msg).each(function(index, value) {
            opt += '<option value="' + msg[index].KeyId + '">' + value.UnitName + '</option>';

        });
        $('#hNUnitsId').html(opt);
        GetRoom.updateDivRooms();
    };

    GetRoom.updateDivRooms = function () {
        $('#hNUnitsId').change(function() {
            var num = $('#hNUnitsId').val();
            if (num != '0') {
                $('#' + num).siblings().hide();
                $('#' + num).show();

            } else {
                $('.easte-unit').show();
            }
        });
    };
//初始化GetRoom对象的方法和属性End

//监测框架房源下拉框的改变状态动态修改栋座信息

    $('#inFrameFlagsId').change(function() {
        var urlNum = window.location.href.split('=')[1].split('#')[0];
        var iFFlag = $('#inFrameFlagsId').val();

        //刷新框架内或框架外数据显示
        $.ajax({
            type: "get",
            url: "/estate/GetRoom",
            data: { 'inFrameFlag': iFFlag, 'estateId': urlNum ,'change':'change'},
            success: function (msg) {
                $('#updateRooms').html(msg);
                selVal();
            }
        });
        
        //刷新选取框的数据

        function selVal() {
            $.ajax({
                type: "get",
                url: "/estate/GetRoomsByHNUnit",
                data: { 'inFrameFlag': iFFlag, 'estateId': urlNum },
                success: function (msg) {
                    GetRoom.getUnitsByIFFlags(msg);
                }
            });
        }

        
    });

    GetRoom.updateDivRooms();
};

